﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi
{
    [CPPEI.WebApi.AuthPostAction("TASK", "Enable", "1.0")]
    public class EnableAction : BaseAction<EnableParams, EnableResult>
    {
        protected override ActionResult<EnableResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            EnableParams opParams)
        {
            SER.TaskService service = new SER.TaskService();
            ServiceResult result = service.Enable(context.UserId, opParams.TaskId);
            if(result.IsSuccess)
            {
                return new ActionResult<EnableResult>(new EnableResult());
            }
            else
            {
                return new ActionResult<EnableResult>(result.IsSuccess, result.ErrorCode, result.Message, null);
            }
        }
    }

    public class EnableParams
    {
        public Guid TaskId { get; set; }
    }

    public class EnableResult
    {
    }
}
